{include file='public/head'}
<body>
<div class="x-body">
    <form class="layui-form" id='mainForm' method="post" action="editUser">

        <input type="hidden" name="id" value="{$data.id}">

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>用户角色</label>
            <div class="layui-input-block">
                <select value="{$data['role_id']}" name="group_id" id='group_id' lay-verify="required" lay-search>
                    <option value="">请选择角色</option>
                    {php}
                    foreach($auth_group as $vo){
                    if($vo['id']==$data['role_id']){
                    {/php}
                    <option value="{$vo.id}" selected>{$vo.title}</option>
                    {php} }else{ {/php}
                    <option value="{$vo.id}">{$vo.title}</option>
                    {php} } } {/php}
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>用户名</label>
            <div class="layui-input-block">
                <input type="text" id="username" value="{$data.username}" name="username" lay-verify="required|username"
                       autocomplete="off" placeholder="请输入用户名，只允许英文数字" class="layui-input" onkeyup="this.value=this.value.replace(/[^\w\.\/]/ig,'')">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>真实姓名</label>
            <div class="layui-input-block">
                <input type="text" id="truename" value="{$data.truename}" name="truename" lay-verify="required" autocomplete="off"
                       placeholder="请输入姓名" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color: red">*</span>邮&nbsp;&nbsp;&nbsp;箱</label>
            <div class="layui-input-block">
                <input type="text" id="email" value="{$data.email}" name="email" lay-verify="required"
                       placeholder="请输入注册邮箱" autocomplete="off" class="layui-input">
            </div>
        </div>

        {if $type == 1 && $data['company_id'] != 0}
        <div class="layui-form-item">
            <label class="layui-form-label">公司名称</label>
            <div class="layui-input-block">
                <input type="text" id="company" value="{$company.name}" name="company" placeholder="请输入公司名称"
                       autocomplete="off" class="layui-input">
                <input type="hidden" id="company_id" name="company_id" value="{$data.company_id}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">空间容量</label>
            <div class="layui-input-block">
                <input type="number" id="upload_capacity" value="{$company.upload_capacity}" name="upload_capacity" autocomplete="off"
                       placeholder="请输入允许上传文件空间大小" class="layui-input" min="0">
                <span style="position:absolute;top:10px;right:20px;">GB</span>
            </div>
        </div>
        {/if}

        <div class="layui-form-item">
            <label class="layui-form-label">启用状态</label>
            <div class="layui-input-block">
                {if $data['status'] == 2}
                <input type="radio" value="1" name="status" title="启用">
                <input type="radio" value="2" name="status" title="禁用" checked>
                {else/}
                <input type="radio" value="1" name="status" title="启用" checked>
                <input type="radio" value="2" name="status" title="禁用">
                {/if}
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">密&nbsp;&nbsp;&nbsp;码</label>
            <div class="layui-input-block">
                <input type="password" id="password" name="password" lay-verify="pass" placeholder="留空为不修改"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">确&nbsp;&nbsp;&nbsp;认</label>
            <div class="layui-input-block">
                <input type="password" id="check_password" name="check_password" placeholder="确认密码" autocomplete="off"
                       class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div>
                <button style="width: 100%" class="layui-btn" lay-submit="" lay-filter="toSubmit">提交保存</button>
            </div>
        </div>

    </form>
</div>
</body>
{include file='public/foot'}
<script type="text/javascript">
    $(document).ready(function () {
        var form = layui.form;
        var layer = layui.layer;
        var options = {
            type: 'post',           //post提交
            // url:'http://ask.tongzhuo100.com/server/****.php?='+Math.random(),   //url
            dataType: "json",        //json格式
            data: {},    //如果需要提交附加参数，视情况添加
            clearForm: false,        //成功提交后，清除所有表单元素的值
            resetForm: false,        //成功提交后，重置所有表单元素的值
            cache: false,
            async: false,          //同步返回
            success: function (data) {
                console.log(data);
                if (data.code == 0) {
                    layer.msg(data.msg);
                } else {
                    layer.msg(data.msg, {icon: 1, time: 500}, function () {
                        $("#reset").click();
                        x_admin_close();
                        parent.location.reload();
                    });
                }
                //服务器端返回处理逻辑
            },
            error: function (XmlHttpRequest, textStatus, errorThrown) {
                layer.msg('操作失败:服务器处理失败');
            }
        };

        // bind form using 'ajaxForm'
        $('#mainForm').ajaxForm(options).submit(function (data) {
        });
    });
</script>
</html>
